﻿using System.Data;

namespace DAL
{
    public static class DalManufacturer
    {
        private static readonly clsConnect cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetManufacturer(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Manufacturer");
        }
        public static DataTable GetManufacturerEdit(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@ID_Manufacturer", id);
            return cls.GetData("sp_tb_Manufacturer_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtManufacturer obj)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Manufacturer_Alias", obj.Manufacturer_Alias);
            cls.AddParameter("@Manufacturer_Name", obj.Manufacturer_Name);
            cls.AddParameter("@Note", obj.Note);
            cls.AddParameter("@Manufacturer_Logo", obj.Manufacturer_Logo);
            cls.AddParameter("@Manufacturer_Adress", obj.Manufacturer_Adress);
            cls.AddParameter("@Manufacturer_Email", obj.Manufacturer_Email);
            cls.AddParameter("@Manufacturer_Phone", obj.Manufacturer_Phone);
            cls.AddParameter("@Manufacturer_Fax", obj.Manufacturer_Fax);
            cls.AddParameter("@Manufacturer_TaxCode", obj.Manufacturer_TaxCode);
            cls.AddParameter("@Manufacturer_Website", obj.Manufacturer_Website);
            cls.AddParameter("@Account_Number", obj.Account_Number);
            cls.AddParameter("@Bank_ID", obj.Bank_ID);
            cls.AddParameter("@DateCreate", obj.DateCreate);
            return cls.ExecuteNonQuery("sp_tb_Manufacturer_Insert");
        }
        public static bool Update(EtManufacturer obj)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@ID_Manufacturer", obj.ID_Manufacturer);
            cls.AddParameter("@Manufacturer_Alias", obj.Manufacturer_Alias);
            cls.AddParameter("@Manufacturer_Name", obj.Manufacturer_Name);
            cls.AddParameter("@Note", obj.Note);
            cls.AddParameter("@Manufacturer_Logo", obj.Manufacturer_Logo);
            cls.AddParameter("@Manufacturer_Adress", obj.Manufacturer_Adress);
            cls.AddParameter("@Manufacturer_Email", obj.Manufacturer_Email);
            cls.AddParameter("@Manufacturer_Phone", obj.Manufacturer_Phone);
            cls.AddParameter("@Manufacturer_Fax", obj.Manufacturer_Fax);
            cls.AddParameter("@Manufacturer_TaxCode", obj.Manufacturer_TaxCode);
            cls.AddParameter("@Manufacturer_Website", obj.Manufacturer_Website);
            cls.AddParameter("@Account_Number", obj.Account_Number);
            cls.AddParameter("@Bank_ID", obj.Bank_ID);
            cls.AddParameter("@DateCreate", obj.DateCreate);
            return cls.ExecuteNonQuery("sp_tb_Manufacturer_Update");
        }
        public static bool Delete(EtManufacturer obj)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@ID_Manufacturer", obj.ID_Manufacturer);
            obj.Msg = cls.ExecuteNonQueryOutput("sp_tb_Manufacturer_DeleteRow", "@MSG");
            return true;
        }
        #endregion
    }

    public class EtManufacturer
    {
        public int ID_Manufacturer { get; set; }
        public string Manufacturer_Alias { get; set; }
        public string Manufacturer_Name { get; set; }
        public string Note { get; set; }
        public string Manufacturer_Logo { get; set; }
        public string Manufacturer_Adress { get; set; }
        public string Manufacturer_Email { get; set; }
        public string Manufacturer_Phone { get; set; }
        public string Manufacturer_Fax { get; set; }
        public string Manufacturer_TaxCode { get; set; }
        public string Manufacturer_Website { get; set; }
        public string Account_Number { get; set; }
        public string DateCreate { get; set; }
        public int ? Bank_ID { get; set; }
        public int Msg { get; set; }
    }
}